<?php

class Application_Model_Product extends Application_Model_DbTable_Product {

    public function GetAllProducts() {
        $select = $this->select();
        return $this->fetchAll($select);
    }
    public function getAllProduct(){
        $select = $this->_db->select()
                        ->from($this->_name);
        $result = $this->getAdapter()->fetchAll($select);
        return $result;
    }
    public function getNewProducts() {
        $select = $this->select()
                        ->order('id DESC')
                        ->limit(6);
        return $this->fetchAll($select);
    }

    public function getRandomProducts() {
//        $arr = array();
//        for ($i = 0; $i < 2; $i++) {
//            $rand = rand(2, 5);
//            array_push($arr, $this->getProduct($rand));
        //$select = $this->select()->order(new Zend_Db_Expr('0*`id`+RAND()));
        return $this->fetchAll($select);
    }

    public function getProducts($id) {
        $select = $this->_db->select()
                        ->from($this->_name)
                        ->where('category_id = ?', $id);
        $result = $this->getAdapter()->fetchAll($select);
        return $result;
    }

    //Mina
    public function getProduct($productid) {
        return $this->find($productid);
    }

}

